package com.liuh.fram.util;

import java.lang.reflect.Field;

import com.jfinal.plugin.activerecord.Record;

/**
 * @note model 常用方法
 * @author liuh
 */
public class ModelKit {

	/**
	 * @note 普通javaBean转换成Record
	 * @author liuh
	 */
	public static Record buildRecord(Class<?> cls, Object obj) throws Exception {
		Record record = new Record();
		Field[] fields = cls.getDeclaredFields();
		for (Field field : fields) {
			field.setAccessible(true);// 设置允许访问
			record.set(field.getName(), field.get(obj));
		}
		return record;
	}
}
